<template>
	<view class="home">
		<!-- 轮播图 -->
		<swiper class="swiper" indicator-dots autoplay circular>
			<swiper-item class="swiper-item" v-for="item in carouselList" :key="item._id">
				<image mode="scaleToFill" :src="item.img_path"></image>
			</swiper-item>
		</swiper>

		<view class="container">
			<!-- 拼卡 -->
			<view class="jigsaw" @click="toJigsaw">我要拼卡</view>
			<view class="more">更多功能,敬请期待</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 轮播图数据
				carouselList: [],
			}
		},
		onLoad() {
			this.getCarousel()
		},
		methods: {
			// 获取轮播图数据
			getCarousel() {
				this.$http({
					name: 'get_sky_carousel',
				}).then((res) => {
					this.carouselList = res
				})
			},
			// 前往拼卡页面
			toJigsaw() {
				uni.navigateTo({
					url: '/pages/jigsaw/jigsaw',
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.home {
		.swiper {
			.swiper-item {
				width: 750rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
		}
		.container {
			display: flex;
			flex-wrap: wrap;
			padding: 20rpx;
			.jigsaw,
			.more {
				width: 47%;
				height: 200rpx;
				line-height: 200rpx;
				text-align: center;
				font-size: 40rpx;
				border-radius: 30rpx;
				background: #f39c12;
				box-sizing: border-box;
				margin: 10rpx;
				color: #fff;
				padding: 0 20rpx;
			}
			.more {
				background: #34495e;
				font-size: 30rpx;
			}
		}
	}
</style>
